<?php

//UMA new
namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class CustomerHistory extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        //return parent::toArray($request);
        return [
            'customer_info' => $this->when($request->output_customer_info !== '0', $this->getMailData()),

            'score_info' => $this->when($request->output_score_info !== '0', [
                'loan_amount_min' => $this->min_total_payment,
                'loan_amount_max' => $this->max_total_payment,
                'score' => $this->score,
                'rate_min' => $this->min_interests,
                'rate_max' => $this->max_interests,
                'rate_message' => $this->getMessage(),
            ]),
            'contact_info' => $this->when($request->output_contact_info !== '0', new ContactInfo($this->contact)),

        ];
    }
}
